<template>
    <div class="ChangeBtnWrap">
        <a-popconfirm :title="`确定修改当前单据为【${item.fireIssearch == '是' ? '未巡检' : '已巡检'}】`" ok-text="确定" cancel-text="取消"
            @confirm="handClick">
            <a-button size="small" type="link">{{ item.fireIssearch == '是' ? '未巡检' : '已巡检' }}</a-button>
        </a-popconfirm>
    </div>
</template>
<script>
export default {
    name: 'ChangeBtn',
    props: {
        item: {
            type: Object,
        },
        onRefresh: {
            type: Function,
        }
    },
    methods: {
        handClick() {
            let isXJ = this.item.fireIssearch == '是' ? '未巡检' : '已巡检';
            let url = {
                '未巡检': this.$notInspected,
                '已巡检': this.$inspected,
            }[isXJ];
            console.log('url==', url);
            let params = {
                id: this.item.id,
            }
            this.getAxios(url, params)
                .then((res) => {
                    if (res.code == 200) {
                        this.$message.success({
                            content: res.msg || res.data,
                            duration: 2.5,
                        });
                        this.onRefresh();
                    }
                })
                .catch(() => { })
                .finally(() => {
                });
        }
    }
}
</script>
<style lang="less" scoped>
.ChangeBtnWrap {
    width: 100%;
    height: 100%;
}
</style>